package com.mallcloud.mall.app.api.entity.vo;

import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

@ApiModel(value="WxPay3NotifyVO",description="微信支付3回调")
@Data
public class WxPay3NotifyVO implements Serializable {
    private static final long serialVersionUID = 1L;

	@ApiModelProperty("通知ID")
    private String id;

	@ApiModelProperty("通知创建时间")
	@JSONField(name = "create_time")
	private String createTime;

	@ApiModelProperty("通知数据类型")
	@JSONField(name = "resource_type")
	private String resourceType;

	@ApiModelProperty("通知类型")
	@JSONField(name = "event_type")
	private String eventType;

	@ApiModelProperty("回调摘要")
	private String summary;

	@ApiModelProperty("通知数据")
	private Resource resource;


	@ApiModel(value="resource",description="微信支付3回调")
    @Data
    public static class Resource{

		@ApiModelProperty("加密算法类型")
		private String algorithm;

		@ApiModelProperty("数据密文")
		@JSONField(name = "ciphertext")
		private String cipherText;

		@ApiModelProperty("附加数据")
		@JSONField(name = "associated_data")
		private String associatedData;

		@ApiModelProperty("原始类型")
		@JSONField(name = "original_type")
		private String originalType;

		@ApiModelProperty("随机串")
        private String nonce;
    }

    public boolean isSuccess() {
        return "TRANSACTION.SUCCESS".equals(this.eventType) && "encrypt-resource".equals(this.resourceType);
    }
}
